package org.qing.config;

import org.qing.config.db.BDbConfig;
import org.qing.config.db.DbManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Configuration
public class BerkleyDBConfig {
	@Autowired
	private BDbConfig bDbConfig;
	
	@Bean
	public DbManager initDbManager() {
		DbManager dbManager = new DbManager();
		if(bDbConfig!=null) {
			log.debug("bDbConfig:{}",bDbConfig);
			dbManager.configEnvironment(bDbConfig);
			dbManager.createDatabase(bDbConfig);
		}
		return dbManager;
	}
}
